using System;
using System.Collections.Generic;
using System.Text;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M009_STORAGE_INPUT_SQL
    {
        #region SQL

        #region INIT_COMBOX_SQL

        private static string _init_COMBOX_SQL = @"
            SELECT   [STOREROOM_ID]
                    ,[STOREROOM_NM]
            FROM     [M008_STOREROOM]
            WHERE    TRANS_STATE <> '3'
			ORDER BY [STOREROOM_ID]";

        #endregion

        #region GET_SINGLE_DATA_SQL
        private static string _get_Single_Data_SQL = @"
            SELECT [CREATE_DATETIME]
                  ,[UPDATE_DATETIME]
                  ,[TRANS_STATE]
                  ,[UPDATER_ID]
                  ,[TERMINAL_CD]
                  ,[STORAGE_ID]                  
                  ,[STOREROOM_ID]
                  ,[GOODS_ID]
                  ,[UNITS]
                  ,[MEMO]
            FROM   [M009_STORAGE]
            WHERE  STORAGE_ID = @STORAGE_ID
            AND TRANS_STATE <> '3'";
        #endregion

        #region GET_SINGLE_GOODS_SQL
        private static string _get_Single_Goods_SQL = @"
            SELECT [CREATE_DATETIME]
                  ,[UPDATE_DATETIME]
                  ,[TRANS_STATE]
                  ,[UPDATER_ID]
                  ,[TERMINAL_CD]
                  ,[STORAGE_ID]                  
                  ,[STOREROOM_ID]
                  ,[GOODS_ID]
                  ,[UNITS]
                  ,[MEMO]
            FROM   [M009_STORAGE]
            WHERE  [GOODS_ID] = @GOODS_ID
            AND    [STOREROOM_ID] = @STOREROOM_ID
            AND    [TRANS_STATE] <> '3'";
        #endregion

        #region INSERT_STORAGE_SQL

        private static string _insert_STORAGE_SQL = @"INSERT INTO [M009_STORAGE](
 [CREATE_DATETIME]
,[UPDATE_DATETIME]
,[TRANS_STATE]
,[UPDATER_ID]
,[TERMINAL_CD]
,[STORAGE_ID]                
,[STOREROOM_ID]
,[GOODS_ID]
,[UNITS]
,[MEMO]
,[PRODUCE_DATE]
,[OVER_PRODUCE_DATE]
,[BUYING_PRICE]
,[SELLING_PRICE]
,[BILL_ID]
,[RED_BLACK])
VALUES(
CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
,CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
,'1'
,@UPDATER_ID
,@TERMINAL_CD
,@STORAGE_ID               
,@STOREROOM_ID
,@GOODS_ID
,@UNITS
,@MEMO
,@PRODUCE_DATE
,@OVER_PRODUCE_DATE
,@BUYING_PRICE
,@SELLING_PRICE
,@BILL_ID
,@RED_BLACK)";

        #endregion

        #region ADD_GOODS_COUNT_SQL
        private static string _add_Goods_Count_SQL = @"UPDATE  [M009_STORAGE]
           SET     [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')               
                  ,[TRANS_STATE] = @TRANS_STATE
                  ,[UNITS] = [UNITS] + @UNITS
           WHERE   [GOODS_ID] = @GOODS_ID
             AND   TRANS_STATE <> '3'";
        #endregion

        #region Update_StorageUnits_SQL
        private static string _update_StorageUnits_SQL = @"UPDATE  [M009_STORAGE]
SET [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')               
,[TRANS_STATE] = '2'
,[UPDATER_ID] = @UPDATER_ID
,[TERMINAL_CD] = @TERMINAL_CD
,[UNITS] = @UNITS
WHERE [GOODS_ID] = @GOODS_ID And BILL_ID = @BILL_ID";
        #endregion

        #region GET_BillIDGoodsID_SQL
        private static string _get_billIdGoodsId_SQL = @"SELECT [GOODS_ID],[BILL_ID]
 FROM   [M009_STORAGE]
 WHERE  [GOODS_ID] = @GOODS_ID And [BILL_ID] = @BILL_ID ";
        #endregion

        #endregion

        #region Proprety

        public static string Init_Combox_SQL
        {
            get
            {
                return _init_COMBOX_SQL;
            }
        }
        
        public static string Get_Single_Data_SQL
        {
            get
            {
                return _get_Single_Data_SQL;
            }
        }
 
        public static string Get_Single_Goods_SQL
        {
            get
            {
                return _get_Single_Goods_SQL;
            }
        }

        public static string Add_Goods_Count_SQL
        {
            get
            {
                return _add_Goods_Count_SQL;
            }
        }

        public static string Insert_STORAGE_SQL
        {
            get
            {
                return _insert_STORAGE_SQL;
            }
        }

        public static string Get_billIdGoodsId_SQL
        {
            get { return _get_billIdGoodsId_SQL; }
        }

        public static string Update_StorageUnits_SQL
        {
            get { return _update_StorageUnits_SQL; }
        }

        #endregion
    }
}
